package presenter;

import base.BasePresenter;
import base.ResultCallBack;
import bean.BooksDatilBean;
import model.BooksDatilModel;
import view.BooksDatilView;

/**
 * Created by 裘翔 on 2019/11/8.
 */

public class BooksDatilPresenter extends BasePresenter<BooksDatilView> implements ResultCallBack<BooksDatilBean> {
    private BooksDatilModel booksDatilModel;

    public BooksDatilPresenter() {
        this.booksDatilModel = new BooksDatilModel();
        addModel(booksDatilModel);
    }

    public void loadData(int id) {
        booksDatilModel.loadData(this, id);
    }

    @Override
    public void onSuccess(BooksDatilBean datilBean) {
        if (mView != null) {
            mView.onSuccess(datilBean);
        }
    }

    @Override
    public void onFail(String error) {
        if (mView != null)
            mView.showToast(error);
        mView.onFailed(error);
    }
}
